import request from 'utils/request';

/**
 * 获取文章列表
 * @param {*} query 筛选文章参数
 * @returns Promise
 */
export const getArticlesAPI = (params) => {
  return request({
    url: '/v1_0/mp/articles',
    params,
  });
};

// 删除功能
export const delArticleByIdAPI = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: 'DELETE',
  });
};
// 发布文章                    // 改造发布接口，支持传参draft表示存为草稿
export const publishArticleAPI = (data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'post',
    data,
  });
};
// 获取文章详情
export const getArticleByIdAPI = (id) => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
  });
};
// 编辑功能
export const updateArticleAPI = (id, data, draft = false) => {
  return request({
    url: `/v1_0/mp/articles/${id}?draft=${draft}`,
    method: 'PUT',
    data,
  });
};
